package com.pucheng.bracelet.viewmodel

import androidx.lifecycle.MutableLiveData
import com.pucheng.bracelet.app.network.apiService
import com.pucheng.bracelet.data.bean.FeedbackBean
import me.hgj.jetpackmvvm.base.viewmodel.BaseViewModel
import com.pucheng.bracelet.app.network.stateCallback.ListDataUiState
import me.hgj.jetpackmvvm.ext.request

class FeedBackViewModel : BaseViewModel() {
    //体系数据
    var helpData: MutableLiveData<ListDataUiState<FeedbackBean>> = MutableLiveData()

    /**
     * 获取faq
     */
    fun getHelpData() {
        request({ apiService.getHelp() }, {
            //请求成功
            val dataUiState =
                ListDataUiState(
                    isSuccess = true,
                    listData = it.lists
                )
            helpData.value = dataUiState
        }, {
            //请求失败
            val dataUiState =
                ListDataUiState(
                    isSuccess = false,
                    errMessage = it.errorMsg,
                    listData = arrayListOf<FeedbackBean>()
                )
            helpData.value = dataUiState
        })
    }

}